<template>
    <div class="app-container">
        <div class="block">
            <el-row>
                <el-col :span="24">
                    <el-button type="success" icon="el-icon-plus" @click.native="add">{{ $t('button.add') }}</el-button>
                    <el-button type="primary" icon="el-icon-edit" @click.native="edit">{{ $t('button.edit') }}</el-button>
                    <el-button type="danger" icon="el-icon-delete" @click.native="remove">{{ $t('button.delete') }}</el-button>
                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
                  @current-change="handleCurrentChange">

            <el-table-column label="序号" type="index" show-overflow-tooltip width="50" align="center">
            </el-table-column>
            <el-table-column label="社区">
                <template slot-scope="scope">
                    {{scope.row.communityName}}
                </template>
            </el-table-column>
            <el-table-column label="大楼">
                <template slot-scope="scope">
                    {{scope.row.buildingName}}
                </template>
            </el-table-column>
            <el-table-column label="层数" align="center">
              <template slot-scope="scope">
                {{scope.row.floor}}
              </template>
            </el-table-column>
            <el-table-column label="编号">
                <template slot-scope="scope">
                    {{scope.row.code}}
                </template>
            </el-table-column>
            <el-table-column label="户型" align="center">
                <template slot-scope="scope">
                    {{scope.row.layout}}
                </template>
            </el-table-column>
            <el-table-column label="朝向" align="center">
                <template slot-scope="scope">
                    {{scope.row.direction}}
                </template>
            </el-table-column>
            <el-table-column label="是否空房" align="center">
                <template slot-scope="scope">
                    {{scope.row.blankFlagName}}
                </template>
            </el-table-column>
            <el-table-column label="建筑面积" align="center">
              <template slot-scope="scope">
                {{scope.row.buildArea}}(平)
              </template>
            </el-table-column>
          <el-table-column label="使用面积" align="center">
            <template slot-scope="scope">
              {{scope.row.useArea}}(平)
            </template>
          </el-table-column>
          <el-table-column label="收费面积" align="center">
            <template slot-scope="scope">
              {{scope.row.feeArea}}(平)
            </template>
          </el-table-column>
            <el-table-column label="创建时间" align="center">
                <template slot-scope="scope">
                    {{scope.row.createTime}}
                </template>
            </el-table-column>
        </el-table>

        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100,500]"
                :page-size="listQuery.limit"
                :total="total"
                @size-change="changeSize"
                @current-change="fetchPage"
                @prev-click="fetchPrev"
                @next-click="fetchNext">
        </el-pagination>

        <el-dialog
                :title="formTitle"
                :visible.sync="formVisible"
                width="70%">
            <el-form ref="form" :model="form" :rules="rules" label-width="150px">
                <el-row>
                    <el-col :span="12">
                        <!--<el-form-item label="社区"  >
                            <el-input v-model="form.communityId" minlength=1></el-input>
                        </el-form-item>-->
                        <el-form-item label="社区" prop="communityId">
                          <el-select v-model="form.communityId" placeholder="请选择" @change="getBuildings">
                            <el-option
                              v-for="item in options.communityIds"
                              :key="item.id"
                              :label="item.name"
                              :value="item.id">
                            </el-option>
                          </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="大楼" prop="buildingId" >
                            <el-select v-model="form.buildingId" placeholder="请选择">
                              <el-option
                                v-for="item in options.buildings"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                              </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="编号" prop="code">
                            <el-input v-model.trim="form.code" minlength=1 placeholder="请输入编号"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否空房" prop="blankFlag" >
                        <el-select v-model="form.blankFlag" placeholder="请选择">
                          <el-option
                            v-for="item in options.blankFlag"
                            :key="item.k"
                            :label="item.v"
                            :value="item.k">
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="户型" prop="layout" >
                            <el-input v-model.trim="form.layout" minlength=1 placeholder="请输入户型"></el-input>
                        </el-form-item>
                    </el-col>
                  <el-col :span="12">
                    <el-form-item label="朝向" prop="direction" >
                      <el-input v-model.trim="form.direction" minlength=1 placeholder="请输入朝向"></el-input>
                    </el-form-item>
                  </el-col>
                    <el-col :span="12">
                      <el-form-item label="层数" prop="floor" >
                        <el-input v-model.trim="form.floor" minlength=1 placeholder="请输入层数">
                          <template slot="append">层</template>
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="建筑面积" prop="buildArea" >
                        <el-input v-model.trim="form.buildArea" minlength=1 placeholder="请输入正数">
                          <template slot="append">平米</template>
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="使用面积" prop="useArea" >
                        <el-input v-model.trim="form.useArea" minlength=1 placeholder="请输入正数">
                          <template slot="append">平米</template>
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="收费面积" prop="feeArea" >
                        <el-input v-model.trim="form.feeArea" minlength=1 placeholder="请输入正数">
                          <template slot="append">平米</template>
                        </el-input>
                      </el-form-item>
                    </el-col>

                </el-row>
                <el-form-item>
                    <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
                    <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
                </el-form-item>

            </el-form>
        </el-dialog>
    </div>
</template>

<script src="./room_info.js"></script>


<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";

    .table-simple-checkbox{
      .el-checkbox__label{
        display: none;
      }
    }
</style>

